package com.eedi.org.hospital.dal.mapper;


import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.org.hospital.dal.dataobject.OrgHospDeptDO;
import com.eedi.org.hospital.controller.vo.dept.OrgHospDeptPageReqVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 医院科室 Mapper
 *
 * @author 永聚长青源码
 */
@Mapper
public interface OrgHospDeptMapper extends BaseMapperX<OrgHospDeptDO> {

    default PageResult<OrgHospDeptDO> selectPage(@Param("reqVO") OrgHospDeptPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrgHospDeptDO>()
                .eqIfPresent(OrgHospDeptDO::getOrgHospitalId, reqVO.getOrgHospitalId())
                .likeIfPresent(OrgHospDeptDO::getOrgDeptName, reqVO.getOrgDeptName())
                .eqIfPresent(OrgHospDeptDO::getOrgStatus, reqVO.getOrgStatus())
                .orderByDesc(OrgHospDeptDO::getOrgHospDeptId));
    }

    default OrgHospDeptDO selectByName(String orgDeptName, String orgHospitalId) {
       return selectOne(new LambdaQueryWrapperX<OrgHospDeptDO>()
               .eq(OrgHospDeptDO::getOrgDeptName, orgDeptName).eq(OrgHospDeptDO::getOrgHospDeptId,orgHospitalId)) ;
    }


}
